/**
 * @description 力扣1679，指针解法，先排序后移动
 * @param {number[]} nums
 * @param {number} k
 * @return {number}
 */
var maxOperations = function (nums, k) {
    let result = 0;
    let numss = nums.sort((a, b) => a - b);
    let left = 0;
    let right = nums.length - 1;
    while (left < right) {
        let temp = numss[left] + numss[right];
        if (temp > k) {
            right--;
        } else if (temp < k) {
            left++;
        } else {
            result++;
            left++;
            right--;
        }
    }
    return result;
};